<div class="content-header">
    <div class="container-fluid">
        <div class="row mb-2">
            <div class="col-sm-6">
                <h1 class="m-0 text-dark">邮箱设置</h1>
            </div><!-- /.col -->
            <div class="col-sm-6">
                <ol class="breadcrumb float-sm-right">
                    <li class="breadcrumb-item"><a th:href="@{admin}">首页</a></li>
                    <li class="breadcrumb-item active">邮箱</li>
                    <li class="breadcrumb-item active">邮箱设置</li>
                </ol>
            </div><!-- /.col -->
        </div><!-- /.row -->
    </div><!-- /.container-fluid -->
</div>
<!-- Main content -->
<section class="content">
    <div class="box box-primary">
        <div class="box-body">
            <form class="form-horizontal" id="cloudConfigForm">
                <div class="form-group">
                    <label class="col-sm-3 control-label">类型 :</label>
                    <div class="btn-group col-sm-8" id="oss-type">
                        <label class="radio-inline pr-5 oss-type-radio active"><input class="active" type="radio" name="type" value="1" > 163邮箱</label>
                        <label class="radio-inline pr-5 oss-type-radio"><input type="radio" name="type" value="2" > QQ邮箱</label>
                        <label class="radio-inline pr-5 oss-type-radio"><input type="radio" name="type" value="3" disabled="disabled"> gmail邮箱</label>
                        <label class="radio-inline pr-5 oss-type-radio"><input type="radio" name="type" value="4"> 其他IMAP协议邮箱</label>
                    </div>
                </div>
                <div id="oss-type-form-group">
                    <div id="oss-type-1">
                        <div class="form-group">
                            <div class="col-sm-8 col-sm-offset-3">
                                <p class="form-control-static">
                                    <a href="https://note.youdao.com/ynoteshare/index.html?id=f9fef46114fb922b45460f4f55d96853&type=note&_time=1657763219355"
                                       target="_blank">如何申请163邮箱API</a></p>
                            </div>
                        </div>
                        <div class="hidden hidden-lg" hidden="hidden">
                            <input name="userId" type="text" th:value="${user?.getUserId()}">
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">邮箱地址 :</label>
                            <div class="col-sm-8 col-md-6">
                                <input th:value="${mailBox?.getEmailAddress()}" type="text" class="form-control" name="emailAddress" require="必填项" domain="" placeholder="">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">AccessKey :</label>
                            <div class="col-sm-8 col-md-6">
                                <input th:value="${mailBox?.getCode()}" type="text" class="form-control" name="code" require="必填项"  placeholder="">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">POP3服务器 :</label>
                            <div class="col-sm-8 col-md-6">
                                <input th:value="${mailBox?.getPopAddress()}" type="text" class="form-control" name="popAddress" require="必填项"  placeholder="pop.163.com">
                            </div>
                            <label class="col-sm-3 control-label">端口 :</label>
                            <div class="col-sm-8 col-md-6">
                                <input th:value="${mailBox?.getPopPort()}" type="text" class="form-control" name="popPort" require="必填项"  placeholder="995">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">SMTP服务器 :</label>
                            <div class="col-sm-8 col-md-6">
                                <input th:value="${mailBox?.getSmtpAddress()}" type="text" class="form-control" name="smtpAddress" require="必填项"  placeholder="smtp.163.com">
                            </div>
                            <label class="col-sm-3 control-label">端口 :</label>
                            <div class="col-sm-8 col-md-6">
                                <input th:value="${mailBox?.getSmtpPort()}" type="text" class="form-control" name="smtpPort" require="必填项"  placeholder="994">
                            </div>
                        </div>
                    </div>
                </div>

                <shiro:hasPermission name="upload:saveConfig">
                <div class="form-group">
                    <div class="col-sm-8  col-sm-offset-3">
                        <button id="saveConfig" type="button" class="btn btn-info">保存</button>
                    </div>
                </div>
                </shiro:hasPermission>
                <!-- /.box-footer -->
            </form>
        </div>
    </div>
</section>
<script type="text/javascript">
    $(function () {

        var menuType = $('input:radio[name="type"]:checked').val();
        $('#oss-type-' + menuType).show().siblings().hide();

        $('input[type=radio][name=type]').change(function () {
            $('#oss-type-' + this.value).show().siblings().hide();
        });


        $("#saveConfig").on('click', function () {
            Core.mask("#saveConfig");
            Core.postAjax("/attachment/saveEmailConfig",$("#cloudConfigForm").serialize(),function (data) {
                Core.unmask("#saveConfig");
                layer.msg(data.msg);
            })

        })
    });
</script>


